<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
	
if ( ! function_exists('vlr_date_picker'))
{   
    
	function vlr_date_picker($label = '',$nombre='')
	{	
             $input  = '<div class="row line narrow clearfix">';
             $input .= '<label><li>'.$label.'</li></label>';
             $input .= '<div class="r"><div class="ui-spinner">';
             $input .= '<input class="validate[required]" type="text" class="datepicker">';
             $input .= '</div>';
             $input .= '</div>';
             $input .= '</div>';                        

            return $input;
	}
}

if ( ! function_exists('vlr_input'))
{   
    
	function vlr_input($label = '',$nombre = '', $id = '', $value = '',$text = '',$place = '')
	{		
             $input  = '<div class="row line narrow clearfix">';
             $input .= '<label><li>'.$label.'</li></label>';
             $input .= '<div class="r"><div class="ui-spinner">';
             $input .= "<input  class='validate[required]' type='text' name='".$nombre."' id='".$id."' original-title='".$text."'  placeholder='".$place."' style='width: 94%;padding: 10px;' "."/>";
             $input .= '</div>';
             $input .= '</div>';
             $input .= '</div>';

            return $input;
	}
}
if ( ! function_exists('vlr_salto'))
{   
	function vlr_salto($numero_salto = '')
	{
            for($i = 0 ; $i < $numero_salto ; $i++)
                echo '<br>';
        }
}
if ( ! function_exists('vlr_input_mail'))
{   
	function vlr_input_mail($label = '',$nombre = '', $id = '', $value = '',$text = '',$place = '')
	{		
             $input  = '<div class="row line narrow clearfix">';
             $input .= '<label><li>'.$label.'</li></label>';
             $input .= '<div class="r"><div class="ui-spinner">';
             $input .= "<input  class='tipRight validate[required]' type='text' name='".$nombre."' id='".$id."' original-title='".$text."'  placeholder='".$place."' style='width: 94%;padding: 10px;' "."/>";
             $input .= '</div>';
             $input .= '</div>';
             $input .= '</div>';
          		
            return $input;
	}
}
if ( ! function_exists('vlr_input_lock'))
{   
	function vlr_input_lock($label='',$nombre = '', $id = '', $value = '',$text = '',$place = '')
	{		
                $input  = '<div class="row line narrow clearfix">';
                $input .= '<label><li>'.$label.'</li></label>';
                $input .= '<div class="r"><div class="ui-spinner">';
                $input .= "<input class='tipRight' readonly='readonly' class='readonly' type='text' name='".$nombre."' id='".$id."' original-title='".$text."' style='width: 94%;padding: 10px;'  value=".$value." />";
                $input .= '</div>';
                $input .= '</div>';
                $input .= '</div>';

		return $input;
	}
}

if ( ! function_exists('vlr_textarea'))
{   
	function vlr_textarea($label = '',$nombre = '', $id = '', $value = '',$text = '',$place = '')
	{		
                $texarea  = '<div class="row line narrow clearfix">';
                $texarea .= '<label><li>'.$label.'</li></label>';
                $texarea .= '<div class="r"><div class="ui-spinner">';                
		$texarea .="<textarea class='resize' type='text' name='".$nombre."' id='".$id."' original-title='".$text."' placeholder='".$place."' style='resize: none; overflow-y: hidden; width: 311px; ' "." ></textarea>";
                $texarea .= '</div>';
                $texarea .= '</div>';
                $texarea .= '</div>';
                
                return $texarea;
	}
}
if ( ! function_exists('vlr_notificacion'))
{   
	function vlr_notificacion($text = '',$tipo = '')
	{		
            if($tipo == 1){
                
		return "<div class='notification green'><p><img src='".  base_url()."img/icons/success.png' alt=''>".$text."<a class='close hider'></a></p></div>";
            }
            if($tipo == 2){
                
		return "<div class='notification blue mt15'><p><img src='".  base_url()."img/icons/info.png' alt=''>".$text."</p><a class='close hider'></a></div>";
            }
            if($tipo == 3){
                
		return "<div class='notification yellow'><p><img src='".  base_url()."img/icons/attention.png' alt=''>".$text."</p><a class='close hider'></a></div>";
            }
            if($tipo == 4){               
		return "<div class='notification red'><p><img src='".  base_url()."img/icons/error.png' alt=''>".$text."</p><a class='close hider'></a></div>";
            }
         
	}
}
if ( ! function_exists('vlr_button_green'))
{   
	function vlr_button_green()
	{		

		return "<input class='btn green submit mt15' type='submit' value='Submit'>";
	}
}
if ( ! function_exists('vlr_button_blue'))
{   
	function vlr_button_blue()
	{		                
		return "<input class='btn blue submit mt15' type='submit' value='Submit'>";
	}
}
if ( ! function_exists('vlr_button_reset'))
{   
	function vlr_button_reset()
	{		

		return "<input class='btn red submit mt15' type='submit' value='Reset'>";
	}
}

if ( ! function_exists('vlr_table'))
{   
	function vlr_table($columna = Array(),$valores = Array(),$nombre =  Array())
	{	
   
            $table = "<table><thead><tr><td></td>";
            //ahora agrego las columnas
            for($i = 0; $i<6;$i++)
            {
                $table .="<th scope='col'>".$columna[$i]."</th>";
            }
            $table .='</tr></thead>';
            $tam_columnas = count($columna);;
            $tam_filas = count($valores);
            
            //echo 'los vvalores son'.count($nombre);
            
            
            $table .= '<tbody>';
            
            for($j=0; $j < $tam_filas; $j++)
            {                
                $table .='<tr><th scope="row">'.$nombre[$j].'</th>';
                for($n = 0; $n< $tam_columnas;$n++)
                {
                   $table .='<td>'.rand(0, 100).'</td>';
                }
                $table .='</tr>';
            }
            
            $table .='</tbody>';
            $table .= ' </table>';
            
           
            return $table;
	}
}

if ( ! function_exists('vlr_table_editable'))
{   
	function vlr_table_editable($columnas = array() ,$filas = array() )
	{	       
            $table = '<table class="display" id="table">';
            $table .= '<thead>';
            $table .= '<tr>';
            $table .= '<th class="readonly check sorting_disabled" rowspan="1" colspan="1" style="width: 78.62962913513184px; ">';
            $table .= '<div class="checker" id="uniform-undefined">';
            $table .= '<span><input type="checkbox" style="opacity: 0; "></span></div></th>';
            $tam_filas = count($filas);
            $tam_columnas = count($columnas);
            
            
            
            for($i = 0;  $i < $tam_columnas ; $i++)
            {             
                $table .='<th class="sorting" rowspan="1" colspan="1" style="width: 100; ">'.$columnas[$i].'</th>';
            }
            $table .='<th class="tview sorting_disabled readonly" rowspan="1" colspan="1" style="width: 30px; ">View</th>';
            $table .='<th class="tedit sorting_disabled readonly" rowspan="1" colspan="1" style="width: 30px; ">Edit</th>';
            $table .='<th class="tdelete sorting_disabled readonly" rowspan="1" colspan="1" style="width: 32px; ">Delete</th></tr>';              
            $table .='</thead><tbody>';
            
            for( $i = 0 ; $i < $tam_filas ; $i++)
            {
                $table .='<tr class="odd">';
                $table .='<td class="readonly check even readonly sorting_1"><div class="checker" id="uniform-undefined"><span><input name="check1" type="checkbox" style="opacity: 0; "></span></div></td>';
                for( $n = 0; $n < $tam_columnas; $n++)
                {
                    $table .='<td class="odd">'.$n.'</td>';
                }
                $table .='<td class="tcontrols even readonly"><a href="#" class="smallbtn"><img src="'.base_url().'img/table/view.png" alt=""></a></td>';
                $table .='<td class="tcontrols odd readonly"><a href="#" class="smallbtn"><img src="'.base_url().'img/table/edit.png" alt=""></a></td>';
                $table .='<td class="tcontrols even readonly"><a href="#" class="smallbtn"><img src="'.base_url().'img/table/delete.png" alt=""></a></td>';
            }
            $table .='</tr></tbody></table>';

            return $table;
	}
}
if ( ! function_exists('vlr_alert_simple'))
{   
	function vlr_alert_simple()
	{		

		return '<a class="btn small green alert_button mrb5">Alert window</a>';
	}
}
if ( ! function_exists('vlr_form_create'))
{   
	function vlr_form_create($titulo = '',$action = '',$form_upload = false)
	{
            $form = '<div class="box onethird">';
            $form .= '<div class="boxheading clearfix"><h3>'.$titulo.'</h3><a class="move"></a></div>';
            $form .= '<section>';
            $form .= '<div class="form">';
            if ($form_upload){
                $form .= '<form enctype="multipart/form-data" action="'.$action.'" id="validation">';
            }else{
                $form .= '<form method="post" action="'.$action.'" id="validation">';
            }

            
		return $form;
	}
}
if ( ! function_exists('vlr_form_close'))
{   
	function vlr_form_close()
	{
            $form = '</form></div></section></div>';                                    
            return $form;
	}
}
if ( ! function_exists('vlr_layout'))
{   
	function vlr_layout($titulo_contenedor = '',$titulo_parrafo = '',$texto_parrafo = '')
	{
            $layout = '<div id="main" class="container_12 clearfix ui-sortable" role="main">';
            $layout .= '<div class="box onethird menu">';
                $layout .= '<section>';
                    $layout .= '<div class="user clearfix">';
                        $layout .= '<div class="l">';
                            $layout .= '<a href="#" class="userimg"><img src="'.  base_url().'img/user.png" alt=""></a>';
                        $layout .= '</div>';
                        $layout .= '<div class="l">';
                            $layout .= '<p><strong>Administrator</strong></p>';
                            $layout .= '<p><a href="#" title="Settings"><img src="'.  base_url().'img/icons/helloadminpack/16x16/17.png" alt="">Settings</a></p>';
                            $layout .= '<p><a href="#" title="Logout"><img src="'.  base_url().'img/icons/helloadminpack/16x16/21.png" alt="">Logout</a></p>';
                        $layout .= '</div>';
                $layout .= '</div>';            
            $layout .= '</section>';
            
            $layout .= '<ul class="clearfix">';
                $layout .= '<li class="first"><a href="./dashboard.html" title="Link title here"><img src="'.  base_url().'img/icons/helloadminpack/16x16/01.png" alt="">Dashboard</a>';
                $layout .= '</li>';
                $layout .= '<li class="hasul"><a href="#" title="Link title here"><img src="'.  base_url().'img/icons/helloadminpack/16x16/03.png" alt="">Layouts</a><span class=""></span>';
                    $layout .= '<ul style="display: none; ">';
                        $layout .= '<li><a href="./layout1.html">2 columns – 1:2 </a></li>';
                        $layout .= '<li><a href="./layout2.html">2 columns – 2:1 </a></li>';
                        $layout .= '<li><a href="./layout2.html">2 columns – 2:1 </a></li>';
                        $layout .= '<li><a href="./layout3.html">1 column </a></li>';
                        $layout .= '<li><a href="./layout4.html">Left menu + 1 column</a></li>';
                        $layout .= '<li><a href="./layout5.html">1 column + Left menu</a></li>';
                        $layout .= '<li><a href="./layout6.html">Left menu + 2 columns </a></li>';
                        $layout .= '<li><a href="./layout7.html">3 columns </a></li>';
                    $layout .= '</ul>';
                $layout .= '</li>';
                
                $layout .= '<li class="hasul"><a href="#" title="Link title here"><img src="'.  base_url().'img/icons/helloadminpack/16x16/02.png" alt="">Modules</a><span class=""></span>';
            $layout .= '<ul style="display: none; ">';
            $layout .= '<li><a href="./gallery.html">Gallery</a></li>';
            $layout .= '<li><a href="./calendar.html">Calendar</a></li>';
            $layout .= '<li><a href="./charts.html">Charts</a></li>';
            $layout .= '<li><a href="./filemanager.html">File Manager</a></li>';
            $layout .= '<li class="last"><a href="./contacts.html">Contacts</a></li>';
            $layout .= '</ul>';
            $layout .= '</li>';
            $layout .= '<li class="hasul last"><a href="#" title="Link title here"><img src="'.  base_url().'img/icons/helloadminpack/16x16/18.png" alt="">Features</a><span class=""></span>';
            $layout .= '<ul style="display: none; ">';
            $layout .= '<li><a href="./tables.html">Tables</a></li>';
            $layout .= '<li><a href="./forms.html">Forms</a></li>';
            $layout .= '<li><a href="./icons.html">Icons, Buttons, Breadcrumbs</a></li>';
            $layout .= '<li><a href="./interface.html">Interface elements</a></li>';
            $layout .= '<li><a href="./typography.html">Typography</a></li>';
            $layout .= '<li class="last hasul"><a href="#">Error pages</a><span></span>';
            $layout .= '<ul>';
            $layout .= '<li><a href="./error1.html">403</a></li>';
            $layout .= '<li><a href="./error2.html">404</a></li>';
            $layout .= '<li><a href="./error3.html">405</a></li>';
            $layout .= '<li><a href="./error4.html">500</a></li>';
            $layout .= '<li class="last"><a href="./error5.html">503</a></li>';
            $layout .= '</ul>';
            $layout .= '</li>';
            $layout .= '</ul>';
            $layout .= '</li>';
            $layout .= '</ul>';
            $layout .= '</div>';
            $layout .= '<div class="box twothirds">';
            $layout .= '<div class="boxheading clearfix"><h3>'.$titulo_contenedor.'</h3><a class="move"></a></div>';
            $layout .= '<section class="clearfix">';
            $layout .= '<h2>'.$titulo_parrafo.'</h2>';
            $layout .= '<p>"'.$texto_parrafo.'.</p>';
            $layout .= '<p>"Mr. Stubb," said I, turning to that worthy, who, buttoned up in his oil-jacket, was now calmly smoking his pipe in the rain; "Mr. Stubb, I think I have heard you say that of all whalemen you ever met, our chief mate, Mr. Starbuck, is by far the most careful and prudent. I suppose then, that going plump on a flying whale with your sail set in a foggy squall is the height of a whalemans discretion?"</p>';
            $layout .= '</section>';
            $layout .= '</div>';
            $layout .= '</div>';
            
            return $layout;
	}
}
if ( ! function_exists('vlr_layout_one_column'))
{   
	function vlr_layout_one_column($titulo_contenedor = '' , $contenido_contenedor = '')
	{
            $layout  = '<div id="main" class="container_12 clearfix ui-sortable" role="main">';
                $layout .= '<div class="box threethirds">';
                    $layout .= '<div class="boxheading clearfix"><h3>Text formatting</h3><a class="move"></a></div>';
                    $layout .= '<section class="clearfix">';
                        $layout .= '<h2>'.$titulo_contenedor.'</h2>';
                        $layout .= '<p>'.$contenido_contenedor.'</p>';                       
                $layout .= '</section>';
                $layout .= '</div>';
            $layout .= '</div>';
            
            
            return $layout;
	}
}
if ( ! function_exists('vlr_drop_down'))
{   
	function vlr_drop_down($titulo_drop_down = '',$datos = array() )
	{
            $drop_down  = '<div class="row line narrow clearfix">';
                $drop_down .= '<label><li>'.$titulo_drop_down.'</li></label>';
                    $drop_down .= '<div class="r">';
                    $drop_down .='<select class="regular" style="opacity: 0; ">';
                    for($i = 0; $i < count($datos) ; $i++){
                        $drop_down .='<option value"'.$i.'">'.$datos[$i].'</option>';
                    }
                    $drop_down .='</select></div></div>';
            $drop_down .= '</div>';
 
            return $drop_down;
	}
}

if ( ! function_exists('vlr_drop_down_db'))
{   
	function vlr_drop_down_db($titulo_drop_down = '',$query = '')
	{
            $drop_down_db  = '<div class="row line narrow clearfix">';
                $drop_down_db .= '<label><li>'.$titulo_drop_down.'</li></label>';
                    $drop_down_db .= '<div class="r">';
                    $drop_down_db .='<select class="regular" style="opacity: 0; ">';
                    for($i = 0; $i < count($datos) ; $i++){
                        $drop_down_db .='<option value"'.$i.'">'.$datos[$i].'</option>';
                    }
                    $drop_down_db .='</select></div></div>';
            $drop_down_db .= '</div>';
 
            return $drop_down_db;
	}
}

if ( ! function_exists('vlr_radio_button'))
{   
	function vlr_radio_button($nombre_radio_button,$datos = array())
	{
             $radio_button  = '<div class="row line narrow clearfix">';
             $radio_button .= '<label><li>'.$nombre_radio_button.'</li></label>';
             $radio_button .= '<div class="r"><div>';
             $total_columnas = count($datos);
             
                for($i = 0; $i <$total_columnas ; $i++ )
                {
                   $radio_button .= "<input name='radio_button' id='radio_button' class='tipRight validate[required]' type='radio' />".$datos[$i];
                   $radio_button .= "   ";                
                }                
                
             $radio_button .= '</div>';
             $radio_button .= '</div>';
             $radio_button .= '</div>';
 
            return $radio_button;
	}
}
if ( ! function_exists('vlr_checkbox'))
{   
	function vlr_checkbox($titulo_drop_down = '',$datos = array() )
	{
             $checkbox  = '<div class="row line narrow clearfix">';
             $checkbox .= '<label><li>'.$titulo_drop_down.'</li></label>';
             $checkbox .= '<div class="r"><div>';
             $total_columnas = count($datos);
             
                for($i = 0; $i <$total_columnas ; $i++ )
                {
                   $checkbox .= "<input name='checkbox' id='checkbox' class='tipRight validate[required]' type='checkbox' />".$datos[$i];
                   $checkbox .= "   ";                
                }                
                
             $checkbox .= '</div>';
             $checkbox .= '</div>';
             $checkbox .= '</div>';
            
            
                         
            return $checkbox;
	}
}
if ( ! function_exists('vlr_upload'))
{   
    
	function vlr_upload($titulo_subir_archivo = '')
	{		
             $upload  = '<div class="row line narrow clearfix">';
             $upload .= '<label>'.$titulo_subir_archivo.'</label>';
             $upload .= '<div class="r"><input type="file" class="regularfile" /></div>';
                         
  

            return $upload;
	}
}
if ( ! function_exists('vlr_multiselct'))
{
	function vlr_multiselct($titulo_subir_archivo = '')
	{		
              $multiselect = '<div class="row">';
              $multiselect .= '<label>Regular multiselect</label>';
              $multiselect .= '<div class="clear">&nbsp;</div>';
              $multiselect .= '<select class="multiple" multiple="multiple">';
              $multiselect .= '<option>First option</option>';
              $multiselect .= '<option>First option</option>';
              $multiselect .= '</select>';              
              $multiselect .= '</div>';
            return $multiselect;
	}
}
if ( ! function_exists('vlr_buton_gigantes'))
{   
    
	function vlr_buton_gigantes($titulo_subir_archivo = '')
	{		                          
             $boton_gigante = '<a href="#" class="btn_icon square mrb15"><img src="'.base_url().'img/icons/helloadminpack/32x32/10.png" alt=""><span>'.$titulo_subir_archivo.'</span></a>';                          

              return $boton_gigante;
	}
}
if ( ! function_exists('vlr_button2_textos'))
{   
    
	function vlr_button2_textos($titulo_boton = '',$texto_bajo = '')
	{		                          
             $button_texto = '<a href="#" class="btn_icon textright mrb15"><img src="'.base_url().'img/icons/helloadminpack/32x32/02.png" alt="">';
             $button_texto .= '<span class="l"><span class="title">'.$titulo_boton.'</span><span class="subtitle">'.$texto_bajo.'</span></span>';
             $button_texto .= '</a>';

              return $button_texto;
	}
}

if ( ! function_exists('vlr_breadcums'))
{   
    
	function vlr_breadcums()
	{		                          
             $breadcums = 'breadcums';

              return $breadcums;
	}
}

if ( ! function_exists('vlr_graficos'))
{       //falta controlar los datos de los graficos
	function vlr_graficos()	{
		$grafico  = '<div class="box twothirds">';
		$grafico .= '<div class="boxheading clearfix"><h3><img src="./img/icons/fatcow-hosting-icons/32x32/chart_bar.png" alt="" />Charts</h3><a class="move"></a></div>';
		$grafico .= '<section>';
		$grafico .= '<h4>Chart with bars</h4>';
		$grafico .= '<div id="chart_bars" class="flot_chart" style="width:100%;height:300px;"></div>';		
		$grafico .= '<h4 class="mt15">Chart with interactive data points</h4>';
		$grafico .= '<div id="chart" class="flot_chart" style="width:100%;height:300px;"></div>';						
		$grafico .= '</section>';		
                
        	return $grafico;
	}
}
if ( ! function_exists('vlr_example'))
{       //falta controlar los datos de los graficos
	function vlr_example()	{

		$grafico = '</section>';
                
        	return $grafico;
	}
}
///////////////////////////////////////////////////////////////////////////////////////////////
/**
 * Drop-down Menu FROM database
 *
 * @access    public
 * @param    string
 * @param    array
 * @param    string
 * @param    string
 * @return    string
 */
if ( ! function_exists('vlr_dropdown_from_db'))
{
    function vlr_dropdown_from_db($name = '', $sql, $selected = array(), $extra = '',$txt='')
    {
        $CI =& get_instance();
        if($extra){
            $texto=$extra;    
        }else{
            $texto="Seleccione una opcion";
            $txt = null;    
        }
        
        if ( ! is_array($selected))
        {
            $selected = array($selected);
        }

        // If no selected state was submitted we will attempt to set it automatically
        if (count($selected) === 0)
        {
            // If the form name appears in the $_POST array we have a winner!
            if (isset($_POST[$name]))
            {
                $selected = array($_POST[$name]);
            }
        }

        if ($extra != '') $extra = ' '.$extra;

        $multiple = (count($selected) > 1 && strpos($extra, 'multiple') === FALSE) ? ' multiple="multiple"' : '';
        $form  = '<div class="row line narrow clearfix">';
        $form .= '<label><li>Titulo</li></label>';
        $form .= '<div class="r">';
        $form .= '<div class="selector hover focus active" id="uniform-undefined">';
        
        
        $form .= '<select class="regular" id="'.$name.'" name="'.$name.'"'.$extra.$multiple.'>';
        if($texto){
            $form.='<option value="'.$txt.'">'.$texto.'</OPTION>';
        } 
        //echo $form;
        $query=$CI->db->query($sql);
        if ($query->num_rows() > 0)
        {
           foreach ($query->result_array() as $row)
           {
                  $values = array_values($row);
                  if (count($values)===2)
                  {
                    $key = (string) $values[0];
                    $val = (string) $values[1];
                  }

                $sel = (in_array($key, $selected))?' selected="selected"':'';

                $form .= '<option  value="'.$key.'"'.$sel.'>'.$val."</option>\n";
           }
        }
        $form .='</select></div></div>';
        $form .= '</div>';
        $form .= '</div>';
        $form .= '</div>';
        
        return $form;
    }    
}

?>		
